/**
 * 双指针 fast   slow
 * fast比slow先走n步  当fast.next==null时 slow刚好走到 要删除节点的前一个节点
 * @param {*} head 
 * @param {*} n 
 * @returns 
 */

var removeNthFromEnd = function(head, n) {
    let dummyHead = new ListNode(-1,head)

    let fast=dummyHead,
        slow=dummyHead;
    while(n>0){
        fast=fast.next
        n--
    }

    while(fast.next){
        fast=fast.next
        slow=slow.next
    }
    slow.next=slow.next.next

    return dummyHead.next

};